Programming with the Kinect™ for Windows® Software Development Kit by David Catuhe
Author:David Catuhe [David Catuhe]
Language: eng
Format: epub
Tags: COMPUTERS / Software Development & Engineering / General
ISBN: 9780735667808
Publisher: Microsoft Press
Published: 2012-09-12T16:00:00+00:00
Creating a learning machine
You now have a good pattern-matching algorithm and a tool to normalize your gestures. You are ready to create the learning machine that will aggregate these two tools. The first step is to create a class to represent the learning machine database.
The RecordedPath class
As explained previously, the learning machine is a database filled with templates of recorded gestures. To represent a template, you can use the following class:
using System; using System.Collections.Generic; using System.Diagnostics; using System.Windows; using Kinect.Toolbox.Gestures.Learning_Machine; // For the GoldenSection methods using System.Windows.Media.Imaging; using System.Windows.Media; namespace Kinect.Toolbox { [Serializable] public class RecordedPath { List<Vector2> points; readonly int samplesCount; [NonSerialized] WriteableBitmap displayBitmap; public List<Vector2> Points { get { return points; } set { points = value; } } public WriteableBitmap DisplayBitmap { get { if (displayBitmap == null) { displayBitmap = new WriteableBitmap(200, 140, 96.0, 96.0, PixelFormats.Bgra32, null); byte[] buffer = new byte[displayBitmap.PixelWidth * displayBitmap.PixelHeight * 4]; foreach (Vector2 point in points) { int scaleX = (int)((point.X + 0.5f) * displayBitmap.PixelWidth); int scaleY = (int)((point.Y + 0.5f) * displayBitmap.PixelHeight); for (int x = scaleX - 2; x <= scaleX + 2; x++) { for (int y = scaleY - 2; y <= scaleY + 2; y++) { int clipX = Math.Max(0, Math.Min(displayBitmap.PixelWidth - 1, x)); int clipY = Math.Max(0, Math.Min(displayBitmap.PixelHeight - 1, y)); int index = (clipX + clipY * displayBitmap.PixelWidth) * 4; buffer[index] = 255; buffer[index + 1] = 0; buffer[index + 2] = 0; buffer[index + 3] = 255; } } } displayBitmap.Lock(); int stride = displayBitmap.PixelWidth * displayBitmap.Format.BitsPerPixel / 8; Int32Rect dirtyRect = new Int32Rect(0, 0, displayBitmap.PixelWidth, displayBitmap.PixelHeight); displayBitmap.WritePixels(dirtyRect, buffer, stride, 0); displayBitmap.AddDirtyRect(dirtyRect); displayBitmap.Unlock(); } return displayBitmap; } } public RecordedPath(int samplesCount) { this.samplesCount = samplesCount; points = new List<Vector2>(); } public void CloseAndPrepare() { points = GoldenSection.Pack(points, samplesCount); } public bool Match(List<Vector2> positions, float threshold, float minimalScore, float minSize) { if (positions.Count < samplesCount) return false; if (!positions.IsLargeEnough(minSize)) return false; List<Vector2> locals = GoldenSection.Pack(positions, samplesCount); float score = GoldenSection.Search(locals, points, -MathHelper.PiOver4, MathHelper.PiOver4, threshold); Debug.WriteLine(score); return score > minimalScore; } } }
The RecordedPath class provides the following information:
A list of Vector2 (the template itself)
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8302)
Test-Driven Development with Java by Alan Mellor(6735)
Data Augmentation with Python by Duc Haba(6649)
Principles of Data Fabric by Sonia Mezzetta(6401)
Learn Blender Simulations the Right Way by Stephen Pearson(6299)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(6171)
Hadoop in Practice by Alex Holmes(5959)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5807)
RPA Solution Architect's Handbook by Sachin Sahgal(5567)
Big Data Analysis with Python by Ivan Marin(5369)
The Infinite Retina by Robert Scoble Irena Cronin(5256)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5150)
Pretrain Vision and Large Language Models in Python by Emily Webber(4333)
Infrastructure as Code for Beginners by Russ McKendrick(4095)
Functional Programming in JavaScript by Mantyla Dan(4038)
The Age of Surveillance Capitalism by Shoshana Zuboff(3956)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3808)
Embracing Microservices Design by Ovais Mehboob Ahmed Khan Nabil Siddiqui and Timothy Oleson(3612)
Applied Machine Learning for Healthcare and Life Sciences Using AWS by Ujjwal Ratan(3583)
